<template>
  <div class="th-1">
    <div class="h2-1">最近一学期课程访问量排行</div>
    <div class="nei-1">
      <!-- 表头 -->
      <div class="baotou-1">
        <div class="d-1">学院</div>
        <div class="d-1">课程名称</div>
        <div class="d-1">点击数</div>
      </div>
      <!-- 内容 -->
      <div class="nei-11">
        <el-carousel
          arrow="never"
          :autoplay="true"
          :pause-on-hover="false"
          direction="vertical"
          :interval="2000"
          indicator-position="none"
          class="luo-1"
        >
          <el-carousel-item
            v-for="(group, groupIndex) in groupedData"
            :key="groupIndex"
            class="luo-2"
          >
            <div
              v-for="(item, index) in group"
              :key="`item-${index}`"
              class="neir-o"
            >
              <div class="t-1">{{ item.id }}</div>
              <div class="t-2">{{ item.bmmc }}</div>
              <div class="t-3">{{ item.kcmc }}</div>
              <div class="t-4">{{ item.value }}</div>
            </div>
          </el-carousel-item>
        </el-carousel>
      </div>
    </div>
  </div>
</template>

<script lang="ts" setup>
import { getJrzhidata } from '@/services/index'
import type { Jrks } from '@/types'
import { ref, onMounted, computed } from 'vue'

const arr = ref<Jrks[]>([])
const List = async () => {
  const res = await getJrzhidata()
  arr.value = res.data
}
onMounted(() => {
  List()
})
const groupedData = computed(() => {
  const groups = []
  for (let i = 0; i < arr.value.length; i += 9) {
    groups.push(arr.value.slice(i, i + 9))
  }
  return groups
})
</script>

<style lang="scss" scoped>
.th-1 {
  width: 670px;
  height: 399px;
  background-image: url('../../assets/img/z-1.png');
  background-repeat: no-repeat;
  background-size: 100% 100%;
  margin: 0 5px;
  padding: 10px;
  box-sizing: border-box;
  .h2-1 {
    color: rgb(255, 255, 255);
    font-weight: bold;
    font-family: 'Microsoft Yahei', Arial, 'sans-serif';
    font-size: 22px;
    margin-bottom: 10px;
  }
  .nei-1 {
    width: 100%;
    height: 330px;
    border: 1px solid #fff;
    box-sizing: border-box;
    padding: 10px;
    .baotou-1 {
      display: flex;
      justify-content: space-evenly;
      width: 100%;
      height: 20px;
      .d-1 {
        width: 80px;
        height: 20px;
        // background: #fff;
        // text-align: center;
        color: #fff;
        font-size: 14px;
      }
    }
    .nei-11 {
      width: 620px;
      height: 294px;
      // position: relative;
      // background: red;
      .neir-o {
        display: flex;
        width: 100%;
        will-change: transform;
        margin-bottom: 5px;
        .t-1 {
          width: 20px;
          height: 20px;
          border-radius: 50%;
          background: #f4ff00;
          color: #000;
          text-align: center;
          margin: 3px 75px 3px 0;
          font-size: 14px;
          line-height: 20px;
        }
        .t-2 {
          width: 100px;
          height: 20px;
          color: #fff;

          margin: 3px 40px 0px 0px;
          font-size: 14px;
          white-space: nowrap; /* 禁止换行 */
          overflow: hidden; /* 溢出隐藏 */
          text-overflow: ellipsis; /* 文本溢出时显示省略号 */
        }
        .t-3 {
          width: 100px;
          height: 20px;
          color: #fff;

          margin: 3px 76px 3px 40px;
          font-size: 14px;
          white-space: nowrap; /* 禁止换行 */
          overflow: hidden; /* 溢出隐藏 */
          text-overflow: ellipsis; /* 文本溢出时显示省略号 */
        }
        .t-4 {
          width: 100px;
          height: 20px;
          color: #fff;

          margin: 3px 34px 0 5px;
          font-size: 14px;
          white-space: nowrap; /* 禁止换行 */
          overflow: hidden; /* 溢出隐藏 */
          text-overflow: ellipsis; /* 文本溢出时显示省略号 */
        }
      }
      .luo-1 {
        width: 100%;
        height: 294px;
        //  background: rgb(0, 255, 55);
      }
      .luo-2 {
        width: 100%;
        height: 294px;
        // background: rgb(0, 255, 55);
      }
    }
  }
}
</style>
